<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增供应商主数据')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-supplier-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">组织编码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="orgCode" placeholder="请输入组织编码" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">组织名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="orgName" placeholder="请输入组织名称" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商分类编码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="sortCode" placeholder="请输入供应商分类编码" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商分类名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="sortName" placeholder="请输入供应商分类名称" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商编码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="supCode" placeholder="请输入供应商编码" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="supName" placeholder="请输入供应商名称" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商银行账户编码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" id="accCode" name="accCode" placeholder="请输入供应商银行账户编码" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商银行账户名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="accName" placeholder="请输入供应商银行账户名称" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">开户行名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="bankName" placeholder="请输入开户行名称" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">纳税人识别号：</label>
            <div class="col-sm-8">
                <input class="form-control" id="taxpayerId" type="text" name="taxpayerId" placeholder="请输入纳税人识别号"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">供应商状态：</label>
            <div class="col-sm-8">
                <div class="check-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                    <input type="radio" name="status" th:value="${dict.dictValue}" th:checked="${dict.dictValue=='0'}"
                           th:text="${dict.dictLabel}">
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script>
    var prefix = ctx + "supplier";

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-supplier-add").serializeArray();
            $.operate.save(prefix + "/add", data);
        }
    }

    $("#taxpayerId").blur(function () {
        var reg = /^[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/g;
        var val = $("#taxpayerId").val();
        if (!reg.test(val)) {
            $.modal.alertError('纳税人识别号不符合标准！');
        }
    })

    $("#form-supplier-add").validate({
        onkeyup: false,
        rules: {
            accCode: {
                remote: {
                    url: prefix + "/checkAccCode",
                    type: "post",
                    dataType: "json",
                    data: {
                        "accCode": function () {
                            return $.common.trim($("input[name='accCode']").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return data;
                    }
                }
            },
        },
        messages: {
            "accCode": {
                remote: "银行卡号不存在！"
            }
        },
        focusCleanup: true
    });

</script>
</body>
</html>